
package org.bridgen.lang.semantics.ast;
import java.util.*;


public class NodeAttrDecl extends AttrDecl implements Cloneable {
    public void flushCache() {
        super.flushCache();
    }
     @SuppressWarnings({"unchecked", "cast"})  public NodeAttrDecl clone() throws CloneNotSupportedException {
        NodeAttrDecl node = (NodeAttrDecl)super.clone();
        node.in$Circle(false);
        node.is$Final(false);
    return node;
    }
     @SuppressWarnings({"unchecked", "cast"})  public NodeAttrDecl copy() {
      try {
          NodeAttrDecl node = (NodeAttrDecl)clone();
          if(children != null) node.children = (ASTNode[])children.clone();
          return node;
      } catch (CloneNotSupportedException e) {
      }
      System.err.println("Error: Could not clone node of type " + getClass().getName() + "!");
      return null;
    }
     @SuppressWarnings({"unchecked", "cast"})  public NodeAttrDecl fullCopy() {
        NodeAttrDecl res = (NodeAttrDecl)copy();
        for(int i = 0; i < getNumChildNoTransform(); i++) {
          ASTNode node = getChildNoTransform(i);
          if(node != null) node = node.fullCopy();
          res.setChild(node, i);
        }
        return res;
    }
    // Declared in PrettyPrint.jrag at line 138
    
    
    public void pp(StringBuffer buf) {
    	buf.append(indent() + "attr ");
    	getReturnType().pp(buf);
    	buf.append(" ");
    	getNodeUse().pp(buf);
    	buf.append("." + getName() + " = ");
    	getSearchPattern().pp(buf);
    	buf.append(";\n");
    }

    // Declared in TypeCodeGen.jrag at line 738

	
	public void generateCode(String indent, StringBuffer buf) {
		super.generateCode(indent, buf);
			 
		// Method signature 
		buf.append(indent + "protected " + cacheVariableType() + " " + computeMethod() + "() {\n"); 
		getSearchPattern().generateCode(indent + INDENT, buf);
		buf.append(indent + "}\n\n");
	}

    // Declared in bridgit.ast at line 3
    // Declared in bridgit.ast line 37

    public NodeAttrDecl() {
        super();


    }

    // Declared in bridgit.ast at line 10


    // Declared in bridgit.ast line 37
    public NodeAttrDecl(NodeUse p0, String p1, NodeUse p2, SearchPattern p3) {
        setChild(p0, 0);
        setName(p1);
        setChild(p2, 1);
        setChild(p3, 2);
    }

    // Declared in bridgit.ast at line 17


  protected int numChildren() {
    return 3;
  }

    // Declared in bridgit.ast at line 20

  public boolean mayHaveRewrite() { return false; }

    // Declared in bridgit.ast at line 2
    // Declared in bridgit.ast line 36
    public void setNodeUse(NodeUse node) {
        setChild(node, 0);
    }

    // Declared in bridgit.ast at line 5

    public NodeUse getNodeUse() {
        return (NodeUse)getChild(0);
    }

    // Declared in bridgit.ast at line 9


    public NodeUse getNodeUseNoTransform() {
        return (NodeUse)getChildNoTransform(0);
    }

    // Declared in bridgit.ast at line 2
    // Declared in bridgit.ast line 36
    public void setName(String value) {
        tokenString_Name = value;
    }

    // Declared in bridgit.ast at line 5

    public String getName() {
        return tokenString_Name != null ? tokenString_Name : "";
    }

    // Declared in bridgit.ast at line 2
    // Declared in bridgit.ast line 37
    public void setReturnType(NodeUse node) {
        setChild(node, 1);
    }

    // Declared in bridgit.ast at line 5

    public NodeUse getReturnType() {
        return (NodeUse)getChild(1);
    }

    // Declared in bridgit.ast at line 9


    public NodeUse getReturnTypeNoTransform() {
        return (NodeUse)getChildNoTransform(1);
    }

    // Declared in bridgit.ast at line 2
    // Declared in bridgit.ast line 37
    public void setSearchPattern(SearchPattern node) {
        setChild(node, 2);
    }

    // Declared in bridgit.ast at line 5

    public SearchPattern getSearchPattern() {
        return (SearchPattern)getChild(2);
    }

    // Declared in bridgit.ast at line 9


    public SearchPattern getSearchPatternNoTransform() {
        return (SearchPattern)getChildNoTransform(2);
    }

    // Declared in NameAnalysis.jrag at line 109
 @SuppressWarnings({"unchecked", "cast"})     public boolean isNodeAttr() {
        boolean isNodeAttr_value = isNodeAttr_compute();
        return isNodeAttr_value;
    }

    private boolean isNodeAttr_compute() {  return true;  }

    // Declared in TypeAnalysis.jrag at line 75
 @SuppressWarnings({"unchecked", "cast"})     public String returnType() {
        String returnType_value = returnType_compute();
        return returnType_value;
    }

    private String returnType_compute() {  return getReturnType().getName();  }

    // Declared in TypeCodeGen.jrag at line 549
 @SuppressWarnings({"unchecked", "cast"})     public boolean isNodeAttrDecl() {
        boolean isNodeAttrDecl_value = isNodeAttrDecl_compute();
        return isNodeAttrDecl_value;
    }

    private boolean isNodeAttrDecl_compute() {  return true;  }

    // Declared in TypeCodeGen.jrag at line 736
 @SuppressWarnings({"unchecked", "cast"})     public String cacheVariableType() {
        String cacheVariableType_value = cacheVariableType_compute();
        return cacheVariableType_value;
    }

    private String cacheVariableType_compute() {  return getReturnType().getName();  }

public ASTNode rewriteTo() {
    return super.rewriteTo();
}

}
